package Year22_Month06.day17;

import java.util.ArrayList;
import java.util.List;


public class 关于树左下角的值的尝试 {
    //因为我不是很懂哈，如果说我调换了层序遍历左右子树的遍历顺序，然后存储所有的值的话，那最下边最左边的那个值不就是存储的最后一个值嘛
    public static int findBottomLeftValue(TreeNode root) {
        List<Integer> list = new ArrayList<>();
        solve(root,list);
        int a = list.get(list.size() - 1);
        return a;
    }

    public static void solve(TreeNode node,List<Integer> list){
        if(node == null) return;
        list.add(node.val);
        solve(node.right,list);
        solve(node.left,list);
    }

    public static void main(String[] args) {
        TreeNode n1 = new TreeNode(2);
        TreeNode n2 = new TreeNode(1);
        TreeNode n3 = new TreeNode(3);
        n1.left = n2;
        n1.right = n3;
        int a = findBottomLeftValue(n1);
        System.out.println(a);
    }
}
